package com.javaspeak.concurrency.structures.map;

/**
 * KeyValuePair encapsulates a Key Value pair
 *
 * It is set atomically into BucketImpl
 *
 * @author John Dickerson
 *
 * @param <K> Key of ConcurrentMap
 * @param <V> Value of ConcurrentMap
 */
public final class KeyValuePair<K,V> {

    private final K key;
    private final V value;


    /**
     * Constructor
     *
     * @param key Key of ConcurrentMap
     * @param value Value of ConcurrentMap
     */
    public KeyValuePair( K key, V value ){

        this.key = key;
        this.value = value;
    }


    public K getKey(){

        return this.key;
    }


    public V getValue(){

        return this.value;
    }


    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString(){

        StringBuilder sb = new StringBuilder();
        sb.append( this.key ).append( ":" ).append( value );

        return sb.toString();
    }
}
